import java.util.Stack;

/**
 * @author LKQ
 * @date 2021/12/24 20:25
 * @description
 */
class MyQueue {
    Stack<Integer> s1;
    Stack<Integer> s2;
    private int front;
    public MyQueue() {
        s1  = new Stack<>();
        s2  = new Stack<>();
    }

    /**
     * 入栈
     * @param x 入栈元素
     */
    public void push(int x) {
        if (s1.empty()) {
            front = x;
        }
        while (!s1.isEmpty()) {
            s2.push(s1.pop());
        }
        s2.push(x);
        while (!s2.isEmpty()) {
            s1.push(s2.pop());
        }
    }

    public void pop() {
        s1.pop();
        if (!s1.isEmpty()) {
            front = s1.peek();
        }
    }

    public int peek() {
        return front;
    }
    public boolean empty() {
        return s1.isEmpty();
    }
}
